<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-container">

    <div class="layui-form layui-input-inline layuimini-form" th:object="${user1}">
        <input type="hidden" th:field="*{u_id}">
        <div class="layui-form-item">
            <label class="layui-form-label required">用户名</label>
            <div class="layui-input-block" >
                <input type="text" th:field="*{name}" id="name" name="name" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="111"  class="layui-input">

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">性别</label>
            <div class="layui-input-block">
                <select name="sex" id="sex" th:field="*{sex}">
                    <option value="">请输入性别</option>
                    <option value="男">男</option>
                    <option value="女">女</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">年龄</label>
            <div class="layui-input-block">
                <input type="number" th:field="*{age}" id="age" name="age" lay-verify="required" lay-reqtext="年龄不能为空" placeholder="请输入年龄" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">部门</label>
            <div class="layui-input-block">
                <input type="text" th:field="*{department}" id="stu_id" name="stu_id" lay-verify="required" lay-reqtext="学号不能为空" placeholder="请输入学号" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">电话</label>
            <div class="layui-input-block">
                <input type="text" th:field="*{phone_number}" id="phone_number" name="phone_number" lay-verify="required" lay-reqtext="电话号码不能为空" placeholder="请输入电话号码" value="" class="layui-input">
            </div>
        </div>

    <!--    <div class="layui-form-item layui-form-text">-->
    <!--        <label class="layui-form-label">备注信息</label>-->
    <!--        <div class="layui-input-block">-->
    <!--            <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>-->
    <!--        </div>-->
    <!--    </div>-->

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script src="layui/layui.js" type="text/javascript" charset="UTF-8"></script>
<script src="js/jquery-3.6.3.js"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        // $(function () {
        //
        //     // 获取需要编辑的数据的信息
        //     $('#loginRegister').click(function () {
        //         register();
        //     });
        // });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var userData = data.field;
            $.ajax({
                type: 'POST',
                url: window.location.protocol + '//' + window.location.host + '/editQzData',
                dataType: 'html',
                data: JSON.stringify(userData),
                contentType: 'application/json',
                success: function (data) {
                    // 关闭弹出层
                    if (data){
                        parent.layer.msg("提交成功");
                        parent.layui.table.reload('currentTableId');
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        // var iframeIndex = parent.layer.getFrameIndex(window.name);
                        // parent.layer.close(iframeIndex);

                    }else {
                        layer.msg("服务器异常，请稍后重试！");
                    }

                },
                error: function () {
                    //console.log(data);
                    //layer.close(registerLoadIndex);
                    layer.alert("请求超时！")
                }
            });
            return false;
        });

    });
</script>
</body>
</html>